/*
 * @Author: songtao
 * @Date: 2021-11-17 16:49:54
 * @LastEditTime: 2021-11-17 16:54:14
 * @FilePath: \vue-cars\vue-admin\src\store\modules\login.js
 */

import {Login} from "@/api/login.js"

const state = {
  isCollapse: JSON.parse(sessionStorage.getItem("isCollapse")) || false
}

const mutations = {
  SET_ISCOLLAPSE: function(state){
    console.log("login")
    state.isCollapse = !state.isCollapse
    // 存储到本地
    sessionStorage.setItem("isCollapse", JSON.stringify(state.isCollapse))
  }
}

const actions = {
  login(content , data){
    return new Promise((resolve,reject) => {
      // 接口
      Login(data).then((res) => {
        resolve(res)
      }).catch((err) => {
        reject(err)
      })
    })
  }
}

export default {
  namespaced:true,
  state,
  mutations,
  actions
};